 $(document).ready(function() {
   
    $('.addbutt').live('click',function(){
        $(this).html('delete');
        $(this).attr('class','deletebutt');
     
        var appendTxt = "<tr>"+
        "<td> <div class=\"ui-input-datebox ui-shadow-inset ui-corner-all ui-body-c\"><input type=\"text\" name=\"idate[]\" class=\"idate ui-input-text ui-body-c\" size=\"4\" data-role=\"datebox\" data-options=\"{&quot;mode&quot;: &quot;calbox&quot;}\" readonly=\"readonly\"><a href=\"#\" class=\"ui-input-clear ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-btn-icon-notext\" title=\"Open Date Picker\" data-corners=\"true\" data-shadow=\"true\" data-iconshadow=\"true\" data-wrapperels=\"span\" data-icon=\"grid\" data-iconpos=\"notext\" data-theme=\"c\" style=\"vertical-align: middle; display: inline-block; \"><span class=\"ui-btn-inner ui-btn-corner-all\"><span class=\"ui-btn-text\">Open Date Picker</span><span class=\"ui-icon ui-icon-grid ui-icon-shadow\">&nbsp;</span></span></a></div></td>"
        
        +"<td><textarea name=\"inotes\" class=\"ui-input-text ui-body-c ui-corner-all ui-shadow-inset\" ></textarea></td>"
        +"<td><input type=\"text\" name=\"iaction[]\"  class=\"iaction ui-input-text ui-body-c ui-corner-all ui-shadow-inset\" size=\"4\"></td>"
        
        +"<td><input type=\"text\" name=\"assign[]\"  class=\"iassign ui-input-text ui-body-c ui-corner-all ui-shadow-inset\" size=\"4\"></td>"
        
        +"<td><div class=\"ui-input-datebox ui-shadow-inset ui-corner-all ui-body-c\"><input type=\"text\" name=\"idoneby[]\" class=\"idoneby ui-input-text ui-body-c\" size=\"4\" data-role=\"datebox\" data-options=\"{&quot;mode&quot;: &quot;calbox&quot;}\" readonly=\"readonly\"><a href=\"#\" class=\"ui-input-clear ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-notext ui-btn-up-c\" title=\"Open Date Picker\" data-corners=\"true\" data-shadow=\"true\" data-iconshadow=\"true\" data-wrapperels=\"span\" data-icon=\"grid\" data-iconpos=\"notext\" data-theme=\"c\" style=\"vertical-align: middle; display: inline-block; \"><span class=\"ui-btn-inner ui-btn-corner-all\"><span class=\"ui-btn-text\">Open Date Picker</span><span class=\"ui-icon ui-icon-grid ui-icon-shadow\">&nbsp;</span></span></a></div></td>"
        
        +"<td><a href=\"#\"  class=\"addbutt ui-link\">add</a></td> </tr>";
        
        
        var appendTxtV2 = "<tr>"
        + "<td><input  type=\"date\" name=\"idate[]\" id=\"idate\" class=\"idate\"   size=\"4\" /></td>" //data-role=\"datebox\" data-options='{\"mode\": \"calbox\"}'
        
        +"<td><textarea name=\"inotes\" ></textarea></td>"                  
        
        +"<td><input  type=\"text\" name=\"iaction[]\"  class=\"iaction\"   size=\"4\" /></td>"
        
        +"<td><input  type=\"text\" name=\"assign[]\"  class=\"iassign\"   size=\"4\" /></td>"
        
        +"<td><input  type=\"date\" name=\"idoneby[]\"  class=\"idoneby\"   size=\"4\" /></td>"
        +"<td><a href=\"#\" class=\"addbutt\">add</a></td></tr>";
        
        $("tr:last").after(appendTxtV2);
        $("table#inotes").trigger('create');
        /*$("tr:last").delegate('a','click',function() {
            var toLoad = this.href;
            
        })*/
    });
    
    $('.deletebutt').live('click',function(){
        $(this).parent().parent().remove();

    });
});